package 代码记录.校招笔试真题.笔试真题_2022.百度;


import java.util.*;

public class Test1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();//游戏的总关卡数
        int m = sc.nextInt();//游戏的总关卡数
        int t = sc.nextInt();//总游戏时长
        int[] arr1 = new int[n + 1];
        int[] arr2 = new int[m + 1];
        for(int i = 1;i <= n;i++){
            arr1[i] = sc.nextInt() + arr1[i - 1];
        }
        for(int i = 1;i <= n;i++){
            arr2[i] = sc.nextInt() + arr2[i - 1];
        }
        int res = Integer.MIN_VALUE;
        for(int i = 0;i <= n;i++){
            for(int j = 0;j <= m;j++){
                if(arr1[i] + arr2[j] <= t){
                    res = Math.max(res,i + j);
                }else{
                    break;
                }
            }
        }
        System.out.println(res);
    }
    public static void main2(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();//游戏的总关卡数
        int m = sc.nextInt();//游戏的总关卡数
        int t = sc.nextInt();//总游戏时长
        int[] arr1 = new int[n];
        int[] arr2 = new int[m];
        for(int i = 0;i < n;i++){
            arr1[i] = sc.nextInt();
        }
        for(int i = 0;i < m;i++){
            arr2[i] = sc.nextInt();
        }
        int res = 0;
        long sum = 0;
        int i = 0,j = 0;
        while(sum <= t && i < n && j < m){
            if(arr1[i] <= arr2[j]){
                sum += arr1[i];
                i++;
                if(sum > t){
                    break;
                }
            }else{
                sum += arr2[j];
                j++;
                if(sum > t){
                    break;
                }
            }
            res++;
        }
        //此时要么sum > t,要摸
        if(sum > t){
            System.out.println(res);
            return;
        }else if(i >= n){
            while(j < m){
                if(sum + arr2[j] <= t){
                    res++;
                    sum += arr2[j];
                    j++;
                }
            }
        }else if(j >= m){
            while(i < n){
                if(sum + arr1[i] <= t){
                    res++;
                    sum += arr1[i];
                    i++;
                }
            }
        }
        System.out.println(res);
    }
}
